<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MOCK</title>
<link href="<%=request.getContextPath()%>/css/global.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/global.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/fingerprint2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jstz.js"></script>
<script type="text/javascript" >

$(function(){
	payMock('7777');
	cardMock('random');
})

var countrys = ['AE','BE','BT','CR','ES','HK'];
var states = ['AL','DC','PA','LA','WA','MO'];
var curs = ['USD','CAD','GBP','CNY','HKD','EUR'];
var products = ['adidas Ace 16 Purecontrol FG - Black/Black/Black','Hogan Interactive Man Hogan Gray','Christian Louboutin Marina Liege 140mm Wedges Black','REEBOK CLASSIC Leather Utility UNISEX SHOES','2015 Nike Mercurial Superfly FG Red Blue','Adidas NMD Runner PK Black Grey'];
var oss = ['Mobile','Windows','Macintosh','Linux','Ubuntu','BlackBerry'];
var browsers = ['MSIE','Chrome','Safari','Firefox','Opera','Netscape'];

var hkdfnames = ['劉','黄','趙','李','钱','吴'];
var hkdlnames = ['德蕐','力錦','小龍','語森','国樂','晟策'];

var usdfnames = ['Anne','Juan','Deiby','Igea','Ricardo','Josep'];
var usdlnames = ['Gonzalez','Martin','Tristan','Rafael','Prados','Moreno'];


var fp = new Fingerprint2({screen_resolution: true});
fp.get(function(result) {
  	$("#finger").val(result);
  	$("#timing").val(jstz.determine().name());
});

function payMock(merNo){
	if(merNo=="7777"){
		$("#no").val("777700");
		$("#key").val("77777777");
	}
	if(merNo=="8888"){
		$("#no").val("888800");
		$("#key").val("88888888");
	}
	$("#order").val(randomNumber(10));
	$("#site").val("mock.atepay.com");
	$("#cur").val(curs[Math.floor(Math.random()*curs.length)]);
	$("#loc").val(Math.floor(randomNumber(2))+"."+randomNumber(2));
	$("#notify").val("http://mock.atepay.com/notify.jsp");
	$("#product").val(products[Math.floor(Math.random()*products.length)]);
}

function cardMock(area){
	if(area=="random"){
		$("#ip").val(randomRangeNumber(1,254)+"."+randomRangeNumber(1,254)+"."+randomRangeNumber(1,254)+"."+randomRangeNumber(1,254));
		$("#os").val(oss[Math.floor(Math.random()*oss.length)]);
		$("#browser").val(browsers[Math.floor(Math.random()*browsers.length)]);
		
		$("#cfname").val(randomNumber(4));
		$("#hfname").val(randomNumber(4));

		$("#clname").val(randomNumber(4));
		$("#hlname").val(randomNumber(4));
		
		$("#cphone").val(randomNumber(3)+"-"+randomNumber(3)+"-"+randomNumber(3));
		$("#hphone").val(randomNumber(3)+"-"+randomNumber(3)+"-"+randomNumber(3));
		
		$("#cemail").val(randomNumber(8)+"@"+randomNumber(3)+".com");
		$("#hemail").val(randomNumber(8)+"@"+randomNumber(3)+".com");
		
		$("#ccountry").val(countrys[Math.floor(Math.random()*countrys.length)]);
		$("#hcountry").val(countrys[Math.floor(Math.random()*countrys.length)]);
		
		$("#cstate").val(states[Math.floor(Math.random()*states.length)]);
		$("#hstate").val(states[Math.floor(Math.random()*states.length)]);
		
		$("#ccity").val(randomNumber(4));
		$("#hcity").val(randomNumber(4));
		
		$("#caddr").val("SomeWhere Street 1234");
		$("#haddr").val("SomeWhere Street 4567");
		
		$("#czip").val(randomNumber(6));
		$("#hzip").val(randomNumber(6));
	}
	if(area=="hkd"){
		$("#ip").val("42.98."+randomRangeNumber(1,254)+"."+randomRangeNumber(1,254));
		$("#os").val(oss[Math.floor(Math.random()*oss.length)]);
		$("#browser").val(browsers[Math.floor(Math.random()*browsers.length)]);
		
		$("#cfname").val(hkdfnames[Math.floor(Math.random()*hkdfnames.length)]);
		$("#hfname").val(hkdfnames[Math.floor(Math.random()*hkdfnames.length)]);

		$("#clname").val(hkdlnames[Math.floor(Math.random()*hkdlnames.length)]);
		$("#hlname").val(hkdlnames[Math.floor(Math.random()*hkdlnames.length)]);
		
		$("#cphone").val(randomNumber(8));
		$("#hphone").val(randomNumber(8));
		
		$("#cemail").val(randomString(8)+"@yahoo.com.hk");
		$("#hemail").val(randomString(8)+"@yahoo.com.hk");
		
		$("#ccountry").val("香港");
		$("#hcountry").val("香港");
		
		$("#cstate").val("新界");
		$("#hstate").val("新界");
		
		$("#ccity").val("青衣");
		$("#hcity").val("青衣");
		
		$("#caddr").val("青衣島灝景灣二期第"+randomNumber(1)+"座"+randomNumber(2)+"樓H");
		$("#haddr").val("青衣島灝景灣二期第"+randomNumber(1)+"座"+randomNumber(2)+"樓H");
		
		$("#czip").val(randomNumber(6));
		$("#hzip").val(randomNumber(6));
	}
	if(area=="usd"){
		$("#ip").val("68.119."+randomRangeNumber(1,254)+"."+randomRangeNumber(1,254));
		$("#os").val(oss[Math.floor(Math.random()*oss.length)]);
		$("#browser").val(browsers[Math.floor(Math.random()*browsers.length)]);
		
		$("#cfname").val(usdfnames[Math.floor(Math.random()*usdfnames.length)]);
		$("#hfname").val(usdfnames[Math.floor(Math.random()*usdfnames.length)]);

		$("#clname").val(usdlnames[Math.floor(Math.random()*usdlnames.length)]);
		$("#hlname").val(usdlnames[Math.floor(Math.random()*usdlnames.length)]);
		
		$("#cphone").val("555-"+randomNumber(3)+"-"+randomNumber(3));
		$("#hphone").val("555-"+randomNumber(3)+"-"+randomNumber(3));
		
		$("#cemail").val(randomString(4)+randomNumber(6)+"@yahoo.com");
		$("#hemail").val(randomString(4)+randomNumber(6)+"@yahoo.com");
		
		$("#ccountry").val("United States");
		$("#hcountry").val("United States");
		
		$("#cstate").val("Alabama");
		$("#hstate").val("Alabama");
		
		$("#ccity").val("Glendale");
		$("#hcity").val("Glendale");
		
		$("#caddr").val(randomNumber(3)+" Myrtle "+randomNumber(3)+" Street");
		$("#haddr").val(randomNumber(3)+" Myrtle "+randomNumber(3)+" Street");
		
		$("#czip").val(randomNumber(5));
		$("#hzip").val(randomNumber(5));
	}
}

function sameMock(){
	$("#hfname").val($("#cfname").val());
	$("#hlname").val($("#clname").val());
	$("#hphone").val($("#cphone").val());
	$("#hemail").val($("#cemail").val());
	$("#hcountry").val($("#ccountry").val());
	$("#hstate").val($("#cstate").val());
	$("#hcity").val($("#ccity").val());
	$("#haddr").val($("#caddr").val());
	$("#hzip").val($("#czip").val());
	$("#hfname").val($("#cfname").val());
	$("#hfname").val($("#cfname").val());
	$("#hfname").val($("#cfname").val());
}

function submitMock(type){
	$("#sform").attr("action",$("#sform").attr("action")+type+".jsp");
	$("#sform").submit();
}

function submitJump(type){
	$("#sform").attr("action",$("#sform").attr("action")+type+".jsp");
	$("#sform").submit();
}
</script>
</head>
<body style="background-color: #1c3e57; margin: 10px;">
	<div style="padding: 25px; margin-bottom:10px;border: 1px dotted #ccc; background-color: #fff;">
		<h1><a href="<%=request.getContextPath (  )%>">首页</a> | 模拟商户网站持卡人信息</h1>
	</div>
	<div style="padding: 25px; border: 1px dotted #ccc; background-color: #fff;">
	<form id="sform" action="<%=request.getContextPath()%>/" method="post">
	<table border="0" width="100%" >
			<tr>
				<td width="25%">支付参数 : &nbsp;&nbsp;<input class="submit" type="button" style="width:50px;" value="7777" onclick="payMock('7777')"><input class="submit"  type="button" style="width:50px;" value="8888" onclick="payMock('8888')"></td>
				<td width="25%">持卡人参数 : &nbsp;&nbsp;<input class="submit" type="button" style="width:50px;" value="随机" onclick="cardMock('random')"><input class="submit" type="button" style="width:50px;" value="香港" onclick="cardMock('hkd')"><input class="submit" type="button" style="width:50px;" value="美国" onclick="cardMock('usd')"></td>
				<td width="25%">收货参数 : &nbsp;&nbsp;</td>
				<td width="25%">账单参数 : &nbsp;&nbsp;<input class="submit" type="button" style="width:50px;" value="一致" onclick="sameMock()"></td>
			</tr>
			<tr>
				<td><hr/></td>
				<td><hr/></td>
				<td><hr/></td>
				<td><hr/></td>
			</tr>
			<tr>
				<td>子帐号:</td>
				<td>IP:</td>
				<td>收货人 FirstName - LastName:</td>
				<td>账单人 FirstName - LastName:</td>
			</tr>
			<tr>
				<td><input style="width: 120px;" type="text" id="no" name="no"></td>
				<td><input style="width: 240px;" type="text" id="ip" name="ip"></td>
				<td><input style="width: 100px;" type="text" id="cfname" name="cfname"> - <input style="width: 100px;" type="text" id="clname" name="clname"></td>
				<td><input style="width: 100px;" type="text" id="hfname" name="hfname"> - <input style="width: 100px;" type="text" id="hlname" name="hlname"></td>
			</tr>
			<tr>
				<td>KEY:</td>
				<td>操作系统:</td>
				<td>收货电话:</td>
				<td>账单电话:</td>
			</tr>
			<tr>
				<td><input style="width: 240px;" type="text" id="key" name="key"></td>
				<td><input style="width: 120px;" type="text" id="os" name="os"></td>
				<td><input style="width: 120px;" type="text" id="cphone" name="cphone"></td>
				<td><input style="width: 120px;" type="text" id="hphone" name="hphone"></td>
			</tr>
			<tr>
				<td>订单号:</td>
				<td>浏览器:</td>
				<td>收货邮箱:</td>
				<td>账单邮箱:</td>
			</tr>
			<tr>
				<td><input style="width: 240px;" type="text" id="order" name="order"></td>
				<td><input style="width: 240px;" type="text" id="browser" name="browser"></td>
				<td><input style="width: 240px;" type="text" id="cemail" name="cemail"></td>
				<td><input style="width: 240px;" type="text" id="hemail" name="hemail"></td>
			</tr>
			<tr>
				<td>来源网址:</td>
				<td>指纹:</td>
				<td>收货国家:</td>
				<td>账单国家:</td>
			</tr>
			<tr>
				<td><input style="width: 240px;" type="text" id="site" name="site"></td>
				<td><input style="width: 240px;" type="text" id="finger" name="finger"></td>
				<td><input style="width: 120px;" type="text" id="ccountry" name="ccountry"></td>
				<td><input style="width: 120px;" type="text" id="hcountry" name="hcountry"></td>
			</tr>
			<tr>
				<td>币种:</td>
				<td>语言类型:</td>
				<td>收货州/省:</td>
				<td>账单州/省:</td>
			</tr>
			<tr>
				<td><input style="width: 60px;" type="text" id="cur" name="cur"></td>
				<td><input style="width: 120px;" type="text" id="locale" name="locale" value="<%=request.getLocale().getCountry()+"|"+request.getLocale().getLanguage()%>"></td>
				<td><input style="width: 120px;" type="text" id="cstate" name="cstate"></td>
				<td><input style="width: 120px;" type="text" id="hstate" name="hstate"></td>
			</tr>
			<tr>
				<td>金额:</td>
				<td>时区:</td>
				<td>收货市:</td>
				<td>账单市:</td>
			</tr>
			<tr>
				<td><input style="width: 120px;" type="text" id="loc" name="loc"></td>
				<td><input style="width: 120px;" type="text" id="timing" name="timing"></td>
				<td><input style="width: 120px;" type="text" id="ccity" name="ccity"></td>
				<td><input style="width: 120px;" type="text" id="hcity" name="hcity"></td>
			</tr>
			<tr>
				<td>通知地址:</td>
				<td>&nbsp;</td>
				<td>收货地址:</td>
				<td>账单地址:</td>
			</tr>
			<tr>
				<td><input style="width: 240px;" type="text" id="notify" name="notify"></td>
				<td>&nbsp;</td>
				<td><input style="width: 240px;" type="text" id="caddr" name="caddr"></td>
				<td><input style="width: 240px;" type="text" id="haddr" name="haddr"></td>
			</tr>
			<tr>
				<td>产品信息:</td>
				<td></td>
				<td>收货邮编:</td>
				<td>账单邮编:</td>
			</tr>
			<tr>
				<td><input style="width: 240px;" type="text" id="product" name="product"></td>
				<td>&nbsp;</td>
				<td><input style="width: 120px;" type="text" id="czip" name="czip"></td>
				<td><input style="width: 120px;" type="text" id="hzip" name="hzip"></td>
			</tr>
			<tr>
				<td>版本号(2.0.1)<input style="width: 120px;" type="hidden" id="version" name="version" value="2.0.1"></td>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td><hr/></td>
				<td><hr/></td>
				<td><hr/></td>
				<td><hr/></td>
			</tr>
			<tr>
				<td align="left">
					<input type="button" class="submit" value="模拟退款" onclick="location.href='<%=request.getContextPath()%>/refund.jsp'">
				</td>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<td align="right">
					<input type="radio" id="jumpType1" name="jumpType" value="wap">移动端
					<input type="radio" id="jumpType2" name="jumpType" value="web" checked="checked">PC端
					<input type="button" class="submit" value="跳转支付" onclick="submitJump('jump')">
					<input type="button" class="submit" value="直联支付" onclick="submitMock('direct')"></td>
			</tr>
		</table>
		</form>
	</div>
</body>